package com.lucun.es_transaction.controller;

import com.lucun.es_transaction.config.RolePermission;
import com.lucun.es_transaction.entity.Address;
import com.lucun.es_transaction.service.AddressService;
import com.lucun.es_transaction.util.AuthorityUtil;
import com.lucun.es_transaction.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    AddressService addressService;

    /*
     * 添加
     * */
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/insert")
    public JsonResult<?> Insert(@RequestBody Address address, HttpServletRequest request) {
        return addressService.insert(address, request);
    }

    /*
     * 删除
     * */
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/delete")
    public JsonResult<?> Delete(Integer id, HttpServletRequest request) {
        return addressService.delete(id, request);
    }

    /*
     * 修改
     * */
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/update")
    public JsonResult<?> Update(@RequestBody Address address, HttpServletRequest request) {
        return addressService.update(address, request);
    }

    //    查询
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/find")
    public List<Address> Find(HttpServletRequest request) {
        return addressService.find(request);
    }
}

